package com.avecsys.quotemanager.ui.components;

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.Date;

import com.avecsys.quotemanager.pojos.QuoteTemplateMasterPojo;
import com.icesoft.faces.context.Resource;

public class QuoteTemplateResource implements Resource, Serializable
{

	public QuoteTemplateResource()
	{
		super();
	}

	private QuoteTemplateMasterPojo quoteTemplateMasterPojo;

	public QuoteTemplateResource(QuoteTemplateMasterPojo quoteTemplateMasterPojo)
	{
		this();
		this.quoteTemplateMasterPojo = quoteTemplateMasterPojo;
	}

	@Override
	public String calculateDigest()
	{
		return null;
	}

	@Override
	public Date lastModified()
	{
		return null;
	}

	@Override
	public InputStream open() throws IOException
	{
		if (quoteTemplateMasterPojo != null)
		{
			try
			{
				return quoteTemplateMasterPojo.getFileContent().getBinaryStream();
			}
			catch (SQLException e)
			{
				e.printStackTrace();
			}
		}
		return null;
	}

	@Override
	public void withOptions(Options arg0) throws IOException
	{

	}

}
